function  [Total_SW,Total_SW_experience,Total_W_avg,Total_ext_avg,Total_gvt_avg]=Total_Welfare_clogit_EEgap_parfor(weight,param,param_FE,param_FEdemo,id_ij,p_elec,t_pigou,d_ext,elec,lifetime,r,MCPF,J,MT,price, price_denom, rebate_estar_denom, estar_denom, kwh, prod_denom,id_i, id_j, id_m, id_n, type_id2_3_demo1_denom, AV_demo1_denom,  ice_sc_demo1_denom, type_id2_3_demo2_denom,   AV_demo2_denom,  ice_sc_demo2_denom,type_id2_3_demo3_denom,   AV_demo3_denom,  ice_sc_demo3_denom,type_id2_3_demo4_denom,   AV_demo4_denom,  ice_sc_demo4_denom,type_id2_3_demo5_denom,  AV_demo5_denom,  ice_sc_demo5_denom, type_id2_3_demo6_denom,  AV_demo6_denom,  ice_sc_demo6_denom)


    param_FE_k=param_FE;
	param_FEdemo_k=param_FEdemo;

dim_k=length(weight)
%parfor k=1:dim_k
for k=1:dim_k

	param_k=param{k};

[Error_i{k}, CS_i{k}, W_i{k}, W_experience_i{k},  Error_avg(k), CS_avg(k), W_avg(k), W_experience_avg(k), ext_i{k}, ext_avg(k), ext_experience_i{k}, ext_experience_avg(k), P_decision_j{k}, P_experience_j{k},gvt_i{k},gvt_avg(k),SW_i{k},SW_avg(k),gvt_experience_i{k},gvt_experience_avg(k),SW_experience_i{k},SW_experience_avg(k)] = ...
Welfare_k_clogit_EEgap_parfor(param_k,param_FE_k,param_FEdemo_k,id_ij,J,p_elec,t_pigou,d_ext,elec,lifetime,r,MCPF,MT,price, price_denom, rebate_estar_denom, estar_denom, kwh, prod_denom,id_i, id_j, id_m, id_n, type_id2_3_demo1_denom, AV_demo1_denom,  ice_sc_demo1_denom, type_id2_3_demo2_denom,   AV_demo2_denom,  ice_sc_demo2_denom,type_id2_3_demo3_denom,   AV_demo3_denom,  ice_sc_demo3_denom,type_id2_3_demo4_denom,   AV_demo4_denom,  ice_sc_demo4_denom,type_id2_3_demo5_denom,  AV_demo5_denom,  ice_sc_demo5_denom, type_id2_3_demo6_denom,  AV_demo6_denom,  ice_sc_demo6_denom);


end

	Total_SW=sum(weight'.*SW_avg);
	Total_SW_experience=sum(weight'.*SW_experience_avg);
	Total_W_avg=sum(weight'.*W_avg);
	Total_ext_avg=sum(weight'.*ext_avg);
	Total_gvt_avg=sum(weight'.*gvt_avg);
 
end